package fr.umlv.escapeir.game;

import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;

class LinearMove implements Behavior {
	
	private static final int TIME = 60;
	private final Body body;
	private final float x;
	private final float y;
	
	private int tick;
	
	LinearMove(Body body, float x, float y) {
		this.body = body;
		this.x = x;
		this.y = y;
	}

	@Override
	public void apply() {
		if (tick > TIME) return;
		if (tick == TIME) body.setLinearVelocity(new Vec2(0,0));
		if (tick == 0) body.applyLinearImpulse(new Vec2(x,y), body.getWorldCenter());
		tick++;
	}
	
	

}
